use napi_derive_ohos::napi;

#[napi(object)]
pub struct AssEvent {
    pub layer: u32,
    pub start: u16,
    pub end: u16,
    pub style: String,
    pub name: String,
    pub margin_left: f64,
    pub margin_right: f64,
    pub margin_top: f64,
    pub margin_bottom: f64,
    pub effect: String,
    pub text: String,
}

#[napi]
#[derive(Clone)]
pub enum Alignment {
    BottomLeft = 1,
    BottomCenter = 2,
    BottomRight = 3,
    MiddleLeft = 4,
    MiddleCenter = 5,
    MiddleRight = 6,
    TopLeft = 7,
    TopCenter = 8,
    TopRight = 9,
}

#[napi]
impl Alignment {
    pub fn from(source: rsubs_lib::util::Alignment) -> Self {
        match source {
            rsubs_lib::util::Alignment::BottomLeft => Alignment::BottomLeft,
            rsubs_lib::util::Alignment::BottomCenter => Alignment::BottomCenter,
            rsubs_lib::util::Alignment::BottomRight => Alignment::BottomRight,
            rsubs_lib::util::Alignment::MiddleLeft => Alignment::MiddleLeft,
            rsubs_lib::util::Alignment::MiddleCenter => Alignment::MiddleCenter,
            rsubs_lib::util::Alignment::MiddleRight => Alignment::MiddleRight,
            rsubs_lib::util::Alignment::TopLeft => Alignment::TopLeft,
            rsubs_lib::util::Alignment::TopCenter => Alignment::TopCenter,
            rsubs_lib::util::Alignment::TopRight => Alignment::TopRight,
        }
    }
}

#[napi(object)]
pub struct AssStyle {
    pub name: String,
    pub font_name: String,
    pub font_size: f64,
    pub primary_color: Option<String>,
    pub secondary_color: Option<String>,
    pub outline_color: Option<String>,
    pub back_color: Option<String>,
    pub bold: bool,
    pub italic: bool,
    pub underline: bool,
    pub strikeout: bool,
    pub scale_x: f64,
    pub scale_y: f64,
    pub spacing: f64,
    pub angle: f64,
    pub border_style: u8,
    pub outline: f64,
    pub shadow: f64,
    pub alignment: Alignment,
    pub margin_left: f64,
    pub margin_right: f64,
    pub margin_top: f64,
    pub margin_bottom: f64,
    pub encoding: f64,
}
